package gdepot

class Category {

   String categoryName
   Category parentCategory
    Set<Category> children

    static belongsTo = [user:User]

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    static hasMany = [goods:Goods,children:Category]
    static constraints = {
        categoryName(unique: true)
        parentCategory nullable: true, blank:true
        children nullable: true,blank:true
    }

    def beforeUpdate(){
        modifiedDate = new Date()
    }

    String toString(){
        categoryName
    }
}
